/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2019 HUST Dian Group
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Original Author: Pengyu Liu <eicliupengyu@gmail.com>
 */

#include "robo-weapon.h"
namespace ns3 {
int
GetHeatOf (AmmoType ammoType, float speed)
{
  switch (ammoType)
    {
    case AmmoType17:
      return speed;
    case AmmoType42:
      return 100;

    default:
      NS_ABORT_MSG ("Unsupport ammo type");
    }
}
float
GetOverspeedLife (AmmoType ammoType, float speed, float maxSpeed, int maxLife)
{
  float deltaSpeed = speed - maxSpeed;
  if (deltaSpeed <= 0)
    return 0;
  switch (ammoType)
    {
    case AmmoType17:
      {
        if (deltaSpeed < 5.f)
          return maxLife * .1f;
        else if (deltaSpeed < 10.f)
          return maxLife * .5f;
        else
          return maxLife;
      }
    case AmmoType42:
      {
        if (speed <= 1.1f * maxSpeed)
          return maxLife * .1f;
        else if (deltaSpeed <= 1.2f * maxSpeed)
          return maxLife * .2f;
        else
          return maxLife * .5f;
      }
    default:
      NS_ABORT_MSG ("Unsupport ammo type");
    }
}
const int gWeaponCoolingValue[MAX_ROBO_TYPE][MAX_WEAPON_ID][MAX_LEVEL] = {
    {
        {40, 60, 80}, //17mm ammo
        {20, 40, 60}, //42mm ammo
    }, //RoboTypeHero
    {
        {40, 60, 80}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeInfantry
    {
        {160, 160, 160}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeSentinel
    {
        {0, 0, 0}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeEngineer
    {
        {M_INT_MAX, M_INT_MAX, M_INT_MAX}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeUVA
    {
        {0, 0, 0}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeTower
};
const int gWeaponMaxHeat[MAX_ROBO_TYPE][MAX_WEAPON_ID][MAX_LEVEL]{
    {
        {240, 360, 480}, //17mm ammo
        {200, 300, 400}, //42mm ammo
    }, //RoboTypeHero
    {
        {240, 360, 480}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeInfantry
    {
        {480, 480, 480}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeSentinel
    {
        {0, 0, 0}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeEngineer
    {
        {M_INT_MAX, M_INT_MAX, M_INT_MAX}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeUVA
    {
        {0, 0, 0}, //17mm ammo
        {0, 0, 0}, //42mm ammo
    }, //RoboTypeTower
};
const int gWeaponMaxAmmoNum[MAX_ROBO_TYPE][MAX_WEAPON_ID] = {
    {500, 50}, //RoboTypeHero
    {500, 0}, //RoboTypeInfantry
    {500, 0}, //RoboTypeSentinel
    {M_INT_MAX, M_INT_MAX}, //RoboTypeEngineer
    {250, 0}, //RoboTypeUVA
    {0, 0}, //RoboTypeTower
};
const int gWeaponInitAmmoNum[MAX_ROBO_TYPE][MAX_WEAPON_ID] = {
    {100, 5}, //RoboTypeHero
    {100, 0}, //RoboTypeInfantry
    {500, 0}, //RoboTypeSentinel
    {0, 0}, //RoboTypeEngineer
    {250, 0}, //RoboTypeUVA
    {0, 0}, //RoboTypeTower
};
const float gWeaponRedius[MAX_WEAPON_ID] = {0.0168f, 0.425f};
const float gWeaponRange[MAX_WEAPON_ID] = {10.f, 7.f};
const float gWeaponMaxSpeed[MAX_WEAPON_ID][MAX_PERFORMANCE_LEVEL] = {
    {10.f, 12.f, 15.f, 30.f}, //17mm ammo
    {8.f, 10.f, 12.f, 16.f}, //42mm ammo
};
const int gWeaponInjury[MAX_WEAPON_ID] = {10, 100};
const Time gWeaponShootDelta[MAX_WEAPON_ID] = {Seconds (0.1), Seconds (1. / 3)};

} // namespace ns3
